<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 自动以动画 */
        @keyframes shake {
            0%{
                transform: translateX(0);
            }

            50%{
                transform: translateX(50px);
            }

            100%{
                transform: translateX(0);
            }
        }

        .box{
            width: 100px;
            height: 100px;
            background-color: aliceblue;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .animation{
            animation: shake 2s infinite alternate;
        }
    </style>
</head>
<body>
    <div id="app">

    </div>
</body>
<script src="js/vue.js"></script>
<script>
    const app = Vue.createApp({
        data(){
            return {
                msg: '动画效果',
                isAnimation: false
            }
        },
        template: `
            <div>
                <div class="box" :class="{animation: isAnimation}">{{msg}}</div>
                <button @click="isAnimation = !isAnimation">开始/结束</button>
            </div>
        `
    }).mount("#app");
</script>
</html>